<?php
/**
 * 【商品】详情接口 
 * @author webopenfather
 */

// 导入公共库文件
include '../../util/function.php';
include '../../util/db.php';

// 1. 接受数据
$goodsId = @$_REQUEST['goodsId'];
if (!$goodsId) response(400, '参数有误');

// 2. 操作数据库（注：$pdo变量在db.php文件中定义了 所以可以直接用）
$pdoStatement = $pdo->query("select * from ecs_goods where goods_id = {$goodsId}");
$data = $pdoStatement->fetch(PDO::FETCH_ASSOC);
if (!$data) response(400, '商品不存在');

// 放大镜图片
$pdoStatement = $pdo->query("select * from ecs_goods_gallery where goods_id = {$data['goods_id']}");
$imgs = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
$data['imgs'] = $imgs;

// 3. 响应数据
response(200, '操作成功', $data);

